import React, { Component } from "react";
import { withRouter } from "react-router-dom";
import { getUserInfo } from "../../api";
import "./index.less";

@withRouter
export default class Mine extends Component {
  state = {
    userInfo: null,
  };

  constructor(props) {
    super(props);
  }

  loadUserInfo() {
    getUserInfo().then((result) => {
      // console.log(result);
      if (result.ret == 200) {
        this.setState({
          userInfo: result.data,
        });
      }
    });
  }

  componentDidMount() {
    this.loadUserInfo();
  }

  render() {
    return (
      <div className="mine">
        <div className="head">
          <div className="user">
            <div className="avatar">
              <img src={this.state.userInfo && this.state.userInfo.img}></img>
            </div>
            <div className="name">
              {this.state.userInfo && this.state.userInfo.name}
            </div>
          </div>
        </div>
        <div className="menu">
          <div
            className="item"
            onClick={() => {
              this.props.history.push("/myMeetingList");
            }}
          >
            <div className="img">
              <img src="/images/wdhy.png"></img>
            </div>
            <div className="text">我的会议</div>
          </div>

          <div
            className="item"
            onClick={() => {
              this.props.history.push("/meetingSignList");
            }}
          >
            <div className="img">
              <img src="/images/hyqd.png"></img>
            </div>
            <div className="text">会议签到</div>
          </div>
          <div
            className="item"
            onClick={() => {
              this.props.history.push("/meetingEvaluation");
            }}
          >
            <div className="img">
              <img src="/images/hwpj.png"></img>
            </div>
            <div className="text">会务评价</div>
          </div>
          <div
            className="item"
            onClick={() => {
              this.props.history.push("/historyTidbit");
            }}
          >
            <div className="img">
              <img src="/images/lshx.png"></img>
            </div>
            <div className="text">历史花絮</div>
          </div>
        </div>
      </div>
    );
  }
}
